//
//  CLfunctionViewController.m
//  I-want-go
//
//  Created by dllo on 15/11/7.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "CLfunctionViewController.h"
#import "CLscreen.h"
#import "CLscanViewController.h"
@interface CLfunctionViewController ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic, retain)UITableView *myTableView;
@property(nonatomic, retain)NSArray *arr;

@end

@implementation CLfunctionViewController
- (void)dealloc {
    [_myTableView release];
    [_arr release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor cyanColor];
    
    self.myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 375 * SWIDTH, 667 * SHEIGHT)];
    [self.view addSubview:self.myTableView];
    [_myTableView release];
    self.myTableView.rowHeight = 70;
    
    UIImageView *imageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"heard.png"]];
    //    imageView.image=[UIImage imageNamed:@"荷花开.png"];
    [self.myTableView setBackgroundView:imageView];
    [imageView release];

    
    self.arr = @[@"版本", @"意见反馈"];
    
    self.myTableView.dataSource = self;
    self.myTableView.delegate = self;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *reuse = @"reuse";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuse];
    }
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.text = self.arr[indexPath.row];
    cell.textLabel.font = [UIFont systemFontOfSize:20];
    //    无色
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0) {
       NSString *version = [self getCurrentLocalVersion];
        NSLog(@"version: %@", version);
        
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:[NSString stringWithFormat:@"当前本版 :%@", version] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
    } else if (indexPath.row == 1) {
        UIAlertController *aleryController = [UIAlertController alertControllerWithTitle:@"不好意思" message:@"亲,真的要反馈么?" preferredStyle:UIAlertControllerStyleAlert];
        [self presentViewController:aleryController animated:YES completion:nil];
        UIAlertAction *leftAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil];
        
        [aleryController addAction:leftAction];
    }
//    else if (indexPath.row == 2) {
////        CLscanViewController *scVC = [[CLscanViewController alloc] init];
////        [self.navigationController pushViewController:scVC animated:YES];
//        NSLog(@"11");
//    }
    
}
// 版本信息
- (NSString *)getCurrentLocalVersion
{
    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
    NSString *appVersion = [infoDic objectForKey:@"CFBundleVersion"];
    return appVersion;
}

- (void)viewWillAppear:(BOOL)animated {
    
    self.tabBarController.tabBar.hidden = YES;
    
}

- (void)viewWillDisappear:(BOOL)animated {
    self.tabBarController.tabBar.hidden = NO;
}













- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    
    
}





/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
